package secondDay;

import javax.rmi.ssl.SslRMIClientSocketFactory;

public class maxProduct {
    public static void main(String[] args) {
        String[] words = {"abcw","baz","foo","bar","fxyz","abcdef"};
        System.out.println(maxProduct(words));
    }

    public static int maxProduct(String[] words){
        int length = words.length;
        int[] masks = new int[length];
        for (int i = 0; i < words.length; i++) {
            String word = words[i];
            int length1 = word.length();
            for (int j = 0; j < length1; j++) {
                masks[i] |= (1 << (word.charAt(j) - 'a'));
            }
        }
        int ans = 0;
        for (int i = 0; i < length; i++) {
            for (int j = i + 1; j < length; j++) {
                if ((masks[i] & masks[j]) == 0) {
                    ans = Math.max(ans, words[i].length() * words[j].length());
                }
            }
        }
        return ans;
    }
}
